#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int LongestComSubstr(string& s1, string& s2){
    size_t len1 = s1.size(), len2 = s2.size();
    if(len1 + len2 == 0) return 0;
    vector<vector<int>> dp(len1+1, vector<int>(len2+1, 0));
    // 遍历dp矩阵
    for(int i = 1; i <= len1; ++i){
        for(int j = 1; j <= len2; ++j){
            // 递推公式
            if(s1[i-1] == s2[j-1])  // 是公共元素
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    return dp[len1][len2];
}

int main()
{
    string s1, s2;
    while(cin >> s1 >> s2){
        cout << LongestComSubstr(s1, s2) << endl;
    }
    return 0;
}

/*  https://programmercarl.com/1143.%E6%9C%80%E9%95%BF%E5%85%AC%E5%85%B1%E5%AD%90%E5%BA%8F%E5%88%97.html#%E6%80%9D%E8%B7%AF  */